Microsoft.Office.Interop.Outlook.

您所在的位置:网站首页 Outlook mailitem displayname Microsoft.Office.Interop.Outlook.

Microsoft.Office.Interop.Outlook.

2023-09-18 05:19| 来源: 网络整理| 查看: 265

Hi,

I had exactly the same problem. Your suggestion of using 'newMail.To(address)' instead of 'newMail.Recipients.Add(address)' is not really helpful because we need the Recipients collection and Recipient object in order e.g. to set the status to Cc or Bcc.

The exception:

System.Runtime.InteropServices.COMException (0x80004004): Operation aborted    at Microsoft.Office.Interop.Outlook._MailItem.get_Recipients()

when sending mail through Outlook 2007 can be avoided by using:

// Create a new MailItem Outlook.MailItem mailItem = (Outlook.MailItem) outlookApp.CreateItem(Outlook.OlItemType.olMailItem);

// trigger viewing the mail (and cause the default stationary to load) mailItem.Display(false);

mailItem.Recipients.Add(address); mailItem.Subject=subject; mailItem.Body = body;

etc. ....

If the line 'mailItem.Display(false)' is omitted, the mentioned exception occurs in Outlook 2007, but in Outlook 2003. If that line is there, it works in both versions.

Haven't tested it yet in Outlook 2010, but I would expect it to work.

Very happy, Ramkanuganti, you gave me the hint to look for a solution when you mentioned the problem wasn't there when Outlook interface was visible ....



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3